Ext.define('qjtravel.view.Spotsign_bak', {
    extend: 'Ext.Panel',
    xtype: 'spotsign',

    config: {
        layout: 'vbox',

        items: [
            {
                xtype:'titlebar',
                title:'景点签到',
                docked: 'top',
                items:[
                    {
                        xtype:'button',
                        text: '帮助',
                        id: 'rightButton',
                        handler:function() {
                            //使用panel做为弹出提示
                            Ext.create('Ext.Panel', {
                                cls:'showHelp',
                                modal: true,
                                hidden: true,
                                left: 0,
                                top: 0,
                                hideOnMaskTap: true,
                                layout: 'fit',
                                style:'	border: 3px solid #000;border-radius: 8px;-webkit-border-radius: 8px;',
                                html: '<div class="signName" style="line-height: 24px; padding: 10px 10px">点击右上角“扫描签到”将镜头对准景区内的二维码，即可在景区签到，点亮景区图标！</div>'
                            }).showBy(this);
                        }
                    } ,
                    {
                        xtype:'button',
                        align:'right',
                        id:'scan',
                        text:'扫描签到',
                        handler:function(){
                            var uuid=localStorage.getItem('uuid');
                                //扫描二维码
                                cordova.exec(function (winParam) {
                                    Ext.Viewport.mask({xtype: 'loadmask' });
                                    Ext.Ajax.request({
                                        url: Global.api_url + '/cloud/1/spotsign_update',
                                        params: {
                                            uuid:uuid,
                                            spotid:winParam
                                        },
                                        scope: this,
                                        success: function (response) {
                                            Ext.Viewport.unmask();
                                            var result = Ext.decode(response.responseText);
                                            if(result.Variables.Result.code == 0){
                                                Ext.getStore('Spotsign').load({params:{uuid:uuid}});
                                            }else{
                                                cordova.exec(function (message) { }, function (error) {
                                                }, "Messages", "showMsg", [result.Variables.Message.messagestr]);
                                                return false;
                                            }
                                        },
                                    failure: function () {
                                        Ext.Viewport.unmask();
                                        cordova.exec(function (message) {
                                        }, function (error) {
                                        }, "Messages", "showMsg", ['请求失败', '服务器维护中....']);
                                        return false;
                                    }
                                });
                            }, function (error) {
                            }, "ScanditSDK", "scan", ["71lJHNykEeKA7i/yJxRDDJxpnvykL5osh6zSD1MsrBA", {"beep": true, "1DScanning": true, "2DScanning": true, "scanningHotspot": "0.5/0.5", "vibrate": true, textForInitialScanScreenState: "将代码框对齐"}]);
                        }
                    }
                ]
            },
            {
                xtype: 'dataview',
                store: 'Spotsign',
                id:'spotsignList',
                height:'100%',
                emptyText: '没有景区',
                itemTpl:
                    "<tpl if='sign==0'>" +
                        "<div style='text-align:center; float: left; width: 33%; padding-top: 4px'>" +
                        "<img src='{image}' height='89px' width='89px'/>" +
                        "<div class='signName'>{name}</div>" +
                        "</div>" +
                    "<tpl else>"+
                        "<div style='text-align:center; float: left; width: 33%;padding-top: 4px'>" +
                        "<img src='{signimage}' height='89px' width='89px'/>" +
                        "<div class='signName'>{name}</div>" +
                        "</div>" +
                    "</tpl>",
               listeners:{
                    painted: function () {
                        Ext.getStore('Spotsign').load({params:{uuid:localStorage.getItem('uuid')}});
                    },
                     itemtap: function (data, index, item, record){
                       Ext.Viewport.animateActiveItem('spotsignDetail',{type: 'slide', direction: 'left'});
                       Ext.getCmp('spotsignDetail').setHtml(
                           '<div style="margin: 20px 10px 10px 10px">' +
                               '<div class="detail_title font2 color1 blod" id="SpotsignName">' + record.get('name') + '</div>' +
                               '</div>'+
                               '<img src='+record.get('signimage')+' width="50%" style="margin:0 25%" id="SpotsignImg" />'+
                               '<div style="margin: 10px" class="content" id="SpotsignContent">' + record.get('explain') + '</div>'
                       );
                   }
                }
            }
        ]
    }
});
